<template>
  <div>
    <el-pagination
      :current-page="currentPage"
      :page-sizes="pageSizes"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script lang="js">
import { getAddBaseApi } from '@/api/employee'
export default {
  prop: {
    total: Number
  },
  name: 'Paginations',
  data() {
    return {
      currentPage: 1, // 当前页码
      pageSizes: [5, 10, 15, 20, 25, 30, 50], // 总页容量
      pageSize: 10, // 分页容量
      page: 1, // 分页
      total: 0, // 总条数
      roleList: [] // 拿到总页数
    }
  },
  mounted() {
    this.getAddBase()
  },
  methods: {
    // 请求数据
    async getAddBase() {
      const res = await getAddBaseApi(
        { page: this.page,
          pagesize: this.pageSize }
      )
      this.roleList = res.data.rows
      this.total = res.data.total
    },
    // 页码容量改变
    handleSizeChange(size) {
      this.pageSize = size

      this.getAddBase()
    },
    // 页码改变
    handleCurrentChange(page) {
      this.page = page

      this.getAddBase()
    }
  }
}
</script>

<style></style>
